package pt.mleiria.sAction.cfg;



import java.util.ArrayList;
import java.util.List;

public class Menu_Item {
	private String name;
	private String link;
	private String capabilities;
	private String visible;
	private List menu_items;
	
	public Menu_Item() {
		menu_items = new ArrayList();
	}
	public void addSubmenu_item(Menu_Item menu_item){
		menu_items.add(menu_item);
	}
	/**
	 * @return the capabilities
	 */
	public String getCapabilities() {
		return capabilities;
	}
	/**
	 * @param capabilities the capabilities to set
	 */
	public void setCapabilities(String capabilities) {
		this.capabilities = capabilities;
	}
	/**
	 * @return the link
	 */
	public String getLink() {
		return link;
	}
	/**
	 * @param link the link to set
	 */
	public void setLink(String link) {
		this.link = link;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the visible
	 */
	public String getVisible() {
		return visible;
	}
	/**
	 * @param visible the visible to set
	 */
	public void setVisible(String visible) {
		this.visible = visible;
	}
	public List getMenu_items() {
		return menu_items;
	}
	/**
	 * 
	 * @param capability um ArrayList com as capacidades (e.g.,00,01,02)
	 * @return 
	 */
	public boolean hasAuthorization(List capacidades){
		boolean result = false;
		String[] menuCapability = this.capabilities.split(",");
		for(int i = 0; i < menuCapability.length; i++){
			if(capacidades.contains(menuCapability[i])){
				result = true;
				break;
			}
		}
		return result;
	}
	

}
